package br.uvv.sao.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;

@Entity
@DiscriminatorValue(value = "Aluno")
public class Aluno extends Usuario {

	private static final long serialVersionUID = -8980272282372729589L;

	@Column(name = "codigo", length = 15, nullable = true)
	private String matricula;

	@OneToMany(fetch = FetchType.LAZY, targetEntity = AlunoOferta.class, mappedBy = "aluno")
	private List<AlunoOferta> matriculadoEm;

	public String getMatricula() {
		return matricula;
	}

	public void setMatricula(String matricula) {
		this.matricula = matricula;
	}

	public List<AlunoOferta> getMatriculadoEm() {
		return matriculadoEm;
	}

	public void setMatriculadoEm(List<AlunoOferta> matriculadoEm) {
		this.matriculadoEm = matriculadoEm;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((matricula == null) ? 0 : matricula.hashCode());
		result = prime * result
				+ ((matriculadoEm == null) ? 0 : matriculadoEm.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Aluno other = (Aluno) obj;
		if (matricula == null) {
			if (other.matricula != null)
				return false;
		} else if (!matricula.equals(other.matricula))
			return false;
		if (matriculadoEm == null) {
			if (other.matriculadoEm != null)
				return false;
		} else if (!matriculadoEm.equals(other.matriculadoEm))
			return false;
		return true;
	}
}
